use driver::{cargo_motor, compr, pick_motor, scan_uart, sensor};

use super::error::{AppErr, ErrorCode};

mod driver;
pub mod status;
pub mod exec;


#[repr(u8)]
#[derive(Clone, Copy, ufmt::derive::uDebug)]
pub enum CargoErr {
    PickAlm = 0x11,
    PickTimeout = 0x12,

    CargoAlm = 0x13,
    CargoTimeout = 0x14,

    ScanTimeout = 0x15,
    ScanInvalid = 0x16,

    CyTopFail = 0x17,
    CyBottomFail = 0x18,
    CyInnerFail = 0x19,
    CyExternFail = 0x1A,

    PickFail = 0x1B,
}

impl ErrorCode for CargoErr {

    fn ec(&self) -> u8 {
        (*self) as _
    }
}

impl From<CargoErr> for AppErr {

    fn from(value: CargoErr) -> Self {
        Self::Other(value)
    }
}

pub fn init_self_driver() {
    sensor::init();
    cargo_motor::init();
    compr::init();
    pick_motor::init();
    scan_uart::init();
}













